@extends('layout.page')
@section('title','渠道 - 列表')
@section('stylesheet')
    <link href="/css/plugins/datepicker/datepicker3.css" rel="stylesheet">
@endsection

@section('static-page')
        <div class="col-sm-12">
            <div class="ibox float-e-margins">
                <div class="ibox-title">
                    <h5>渠道 <small>列表</small></h5>
                </div>
                <div class="ibox-content">
                    <div class="row m-b-md">
                        <div class="form-group">
                            <label class="col-sm-2 control-label">渠道名称</label>
                            <div class="col-sm-6">
                                <input class="form-control" id="keyword" type="text" value="{{$keyword}}">
                            </div>
                        </div>
                    </div>
                    <div class="row m-b-md">
                    <div class="form-group">
                        <label class="col-sm-2 control-label">时间：</label>
                        <div class="col-sm-6">
                            <div class="input-daterange input-group" id="datepicker">
                                <input type="text" class="input-sm form-control" readonly id="date-start" value="{{$start_time}}" />
                                <span class="input-group-addon"> —— </span>
                                <input type="text" class="input-sm form-control" readonly id="date-end" value="{{$end_time}}" />
                            </div>
                        </div>
                    </div>
                        </div>

                    <a class="btn btn-success" id="btn-time">筛选</a>
                    <table class="table table-bordered">
                        <thead>
                        <tr>
                            <th>#</th>
                            <th>名称</th>
                            <th>新增注册数</th>
                            <th>新增实名数</th>
                            <th>实名率</th>
                            <th>订单率</th>
                            <th>复投率</th>
                            <th>总成本</th>
                            <th>总成交金额</th>
                            <th>总ROI</th>
                            <th>操作</th>
                        </tr>
                        </thead>
                        <tbody>
                        @foreach($channel_list as $channel)
                            <tr>
                                <td>{{$channel->id}}</td>
                                <td>{{$channel->name}}</td>
                                <td>{{$channel->reg_num}}</td>
                                <td>{{$channel->real_nu}}</td>
                                <td>{{percent($channel->real_nu,$channel->reg_num)}}</td>
                                <td>{{percent($channel->invest_total_number,$channel->reg_num)}}</td>
                                <td>{{percent($channel->invest_success_number - $channel->invest_first_number,$channel->invest_success_number)}}</td>
                                <td>{{$channel->real_amount}}</td>
                                <td>{{$channel->invest_num}}</td>
                                <td>{{ratio($channel->invest_num,$channel->real_amount)}}</td>
                                <td>
                                    <a href="/ceb/channels/index?channel_provider_id={{$channel->id}}&start_time={{$start_time}}&end_time={{$end_time}}">详情</a>
                                </td>
                            </tr>
                        @endforeach
                        </tbody>
                    </table>
                    @include('wiget.pager',[
                        'page' => $page,
                        'page_size' => $size,
                        'count' => $count,
                        'show_count' => 10,
                        'path' => url('/ceb/channelproviders/index?start_time=' . $start_time . '&end_time=' . $end_time)
                    ])
                    <a class="btn btn-sm btn-primary" href="/ceb/channelproviders/create">添加渠道</a>
                </div>
            </div>
        </div>
@endsection
@section('javascript')
<script src="/js/plugins/datepicker/bootstrap-datepicker.js"></script>
<script>
    $(document).ready(function () {
        $('.i-checks').iCheck({
            checkboxClass: 'icheckbox_square-green',
            radioClass: 'iradio_square-green',
        });

        setDateRange('#date-start','#date-end');

        $('#btn-time').on('click',function(){
            var start = $('#date-start').val();
            var end = $('#date-end').val();
            var keyword = $('#keyword').val();
            go_page('/ceb/channelproviders/index',{
                start_time:start,
                end_time:end,
                keyword:keyword
            });
        });
    });
</script>
@endsection
